//=========================================引脚接线================================================//
//   VCC         接       DC 5V/3.3V      //MPU9250电源正
//   GND         接          GND          //MPU9250电源地
//=======================================液晶屏数据线接线==========================================//
//   SCL         接          PA9         //MPU9250 IIC 时钟信号
//   SDA         接          PA10        //MPU9250 IIC 数据信号
//=================================================================================================//

#include "Task_Compass.h"

QueueHandle_t Usart4_sem;



#define Compass_TASK_PRIO 6
#define Compass_STK_SIZE 1024
TaskHandle_t CompassTask_Handler;
void Task_Compass(void *pvParameters);

void Task_Compass_Create(void)
{
	
	  xTaskCreate((TaskFunction_t )Task_Compass,            //任务函数
                (const char*    )"Task_Compass",          //任务名称
                (uint16_t       )Compass_STK_SIZE,        //任务堆栈大小
                (void*          )NULL,                //传递给任务函数的参数
                (UBaseType_t    )Compass_TASK_PRIO,       //任务优先级
                (TaskHandle_t*  )&CompassTask_Handler);   //任务句柄    
		Usart4_sem = xSemaphoreCreateBinary();
				if(Usart4_sem == NULL)
				{
					while(1)
					{
						;
					}
				}
		//Usart4_sem = xSemaphoreCreateCounting(2,1);        /* 计数信号量创建 */								
}

extern void CompassdAnalyse(char *buf);
void Task_Compass(void *pvParameters)
{

	Uart4_Init(9600);

	
	while(1)
	{
		if(xSemaphoreTake(Usart4_sem, portMAX_DELAY) == pdTRUE)
		{
				//SEGGER_RTT_printf(0, "Usart7_RXBUF\n");
				CompassdAnalyse((char*)Usart4_RXBUF);
				usart_dma_receiver_enable(UART4, TRUE);         //开启USART4 DMA 接收
				dma_channel_enable(DMA1_CHANNEL3, TRUE);        //开启通道3（开始接收）
		}
	}
}






